#import "FlutterUniappPlugin.h"

#import "NativeUniBridge.h"

@implementation FlutterUniappPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
    FlutterMethodChannel* channel = [FlutterMethodChannel
                                     methodChannelWithName:@"flutter_uniapp_plugin"
                                     binaryMessenger:[registrar messenger]];
    FlutterUniappPlugin* instance = [[FlutterUniappPlugin alloc] init];
    [registrar addMethodCallDelegate:instance channel:channel];
}

- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
    if ([@"getPlatformVersion" isEqualToString:call.method]) {
        result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
    }
    
    else if([@"testPlugin" isEqualToString:call.method]){
        [self testPlugin];
        result(@"调用成功");
    }
    
    else if([@"openMiniAPP" isEqualToString:call.method]){
        
         [NativeUniBridge openMiniAPP:call.arguments result:result];
        
    }
    
    else if([@"getUniMPSDKVersion" isEqualToString:call.method]){
        [self testPlugin];
        result(@"调用成功");
    }
    
    else if([@"canOpenMiniAPP" isEqualToString:call.method]){
        [self testPlugin];
        result(@"调用成功");
    }
    
    else if([@"sentMessageToMiniAPP" isEqualToString:call.method]){
        [self testPlugin];
        result(@"调用成功");
    }
    
    else if([@"receiveMessageFromMiniAPP" isEqualToString:call.method]){
        [self testPlugin];
        result(@"调用成功");
    }
    
    else {
        result(FlutterMethodNotImplemented);
    }
}

/// 测试一下 这里写一些方法,会不会被 自动清除
///
-(void) testPlugin{
    
    
    NSLog(@"=====testPlugin===我是iOS 原生端的log========");
}

@end
